/*
moxl - Modular XML Library
Copyright (c) 2007, Malcolm Sparks

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
package moxl.raw;

public class ElementLocation
{
	private final PointLocation openLocation;
	private final PointLocation closeLocation;
	private final XmlResource resource;

	public ElementLocation(XmlResource resource, PointLocation openLocation, PointLocation closeLocation)
	{
		this.resource = resource;
		this.openLocation = openLocation;
		this.closeLocation = closeLocation;
	}

	public PointLocation getOpenElementLocation()
	{
		return openLocation;
	}

	public PointLocation getCloseElementLocation()
	{
		return closeLocation;
	}

	public XmlResource getContainingResource()
	{
		return resource;
	}

	@Override
	public String toString()
	{
		StringBuilder builder = new StringBuilder("{from ");
		builder.append(openLocation);
		builder.append(" to ");
		builder.append(closeLocation);
		if (!resource.isAnonymous())
		{
			builder.append(" in ");
			builder.append(resource);
		}
		builder.append("}");
		return builder.toString();
	}
}
